<?php 
class user_home
{ 
	function home_user_main() 
	{ 
		global $mysql_conn,$v_file;
		$sql = "SELECT * from `web` WHERE `web_isset` = '1';";
		$result = mysql_query($sql,$mysql_conn);
		$row=mysql_fetch_array($result);
		$web_id = $row['web_id'];
		$web_bot = $row['web_bot'];
		$web_name = $row['web_name'];
		$web_url = $row['web_url'];
		$web_title = $row['web_title'];
		$web_keywords = $row['web_keywords'];
		$web_description = $row['web_description'];
		$web_company = $row['web_company'];
		$web_copyright = $row['web_copyright'];
		$web_isset = $row['web_isset'];
		$user_id = $_COOKIE['user_id'];
		$user_name = $_COOKIE['user_name'];
		$user_type = $_COOKIE['user_type'];
		$type_name = $_COOKIE['type_name'];
		require($v_file);
	}
	function home_user_menu() 
	{ 
		global $mysql_conn;
		//管理员菜单
		$user_type = $_COOKIE['user_type'];
		$menu_admin_list .= "<li><a href='#'><i class='fa fa-cog'></i><span class='nav-label'>管理中心</span><span class='fa arrow'></span></a>";
		$menu_admin_list .= "<ul class='nav nav-second-level'>";
		$sql_system_sub = "SELECT * from `system` WHERE `sub_type` = 'system';";
		$result_system_sub = mysql_query($sql_system_sub,$mysql_conn);
		while(@$row_system_sub=mysql_fetch_array($result_system_sub)) {
			$sub_access = $row_system_sub['sub_access'];
			$sql_sub_c = "SELECT * from `".$sub_access."_conf` WHERE `conf_c` = '1' and `conf_menu` = 'admin';";
			$result_sub_c = mysql_query($sql_sub_c,$mysql_conn);
			while(@$row_sub_c=mysql_fetch_array($result_sub_c)) {
				$conf_name = $row_sub_c['conf_name'];
				$conf_url = $row_sub_c['conf_url'];
				$conf_sub = $row_sub_c['conf_sub'];
				$conf_istype = $row_sub_c['conf_istype'];
				$conf_istype_arr = explode(',',$conf_istype); 
				if (in_array($user_type, $conf_istype_arr)) {
					$sql_sub_a = "SELECT * from `".$sub_access."_conf` WHERE `conf_a` = '1' and `conf_menu` = 'admin';";
					$result_sub_a = mysql_query($sql_sub_a,$mysql_conn);
					$menu_admin_list .= "<li id='c_li_".$conf_sub."' >";
					if (mysql_num_rows($result_sub_a) > 0) {
						$menu_admin_list .= "<a href='#' id='c_a_".$conf_sub."' >".$conf_name."<span class='fa arrow'></span></a>";
					} else {
						$menu_admin_list .= "<a class='J_menuItem' href='".$conf_url."' id='c_a_".$conf_sub."' >".$conf_name."</a>";
					}
					if (mysql_num_rows($result_sub_a) > 0) $menu_admin_list .= "<ul class='nav nav-third-level' id='c_ul_".$conf_sub."'>";
					while(@$row_sub_a=mysql_fetch_array($result_sub_a)) {
						$conf_name = $row_sub_a['conf_name'];
						$conf_url = $row_sub_a['conf_url'];
						$conf_sub = $row_sub_a['conf_sub'];
						$menu_admin_list .= "<li id='a_li_".$conf_sub."' ><a class='J_menuItem' href='".$conf_url."' id='a_li_".$conf_sub."' >".$conf_name.$i."</a></li>";
					}
					if (mysql_num_rows($result_sub_a) > 0) $menu_admin_list .= "</ul>";
					$menu_admin_list .= "</li>";
				}
			}
		}
		$menu_admin_list .= "</ul></li>";
		if ($user_type < 6) {
			echo $menu_admin_list;
		}
		//用户菜单
		$sql_system_sub = "SELECT * from `system` WHERE `sub_type` = 'system';";
		$result_system_sub = mysql_query($sql_system_sub,$mysql_conn);
		while(@$row_system_sub=mysql_fetch_array($result_system_sub)) {
			$sub_access = $row_system_sub['sub_access'];
			$sql_sub_c = "SELECT * from `".$sub_access."_conf` WHERE `conf_c` = '1' and `conf_menu` = 'user';";
			$result_sub_c = mysql_query($sql_sub_c,$mysql_conn);
			while(@$row_sub_c=mysql_fetch_array($result_sub_c)) {
				$conf_name = $row_sub_c['conf_name'];
				$conf_url = $row_sub_c['conf_url'];
				$conf_ico = $row_sub_c['conf_ico'];
				$conf_sub = $row_sub_c['conf_sub'];
				$sql_sub_a = "SELECT * from `".$sub_access."_conf` WHERE `conf_a` = '1' and `conf_menu` = 'user';";
				$result_sub_a = mysql_query($sql_sub_a,$mysql_conn);
				$menu_user_list .= "<li id='c_li_".$conf_sub."'>";
				if (mysql_num_rows($result_sub_a) > 0) {
					$menu_user_list .= "<a href='#' id='c_a_".$conf_sub."'><i class='fa fa-".$conf_ico."'></i><span class='nav-label'>".$conf_name."</span><span class='fa arrow'></span></a>";
				} else {
					$menu_user_list .= "<a class='J_menuItem' href='".$conf_url."' id='c_a_".$conf_sub."'><i class='fa fa-".$conf_ico."'></i><span class='nav-label'>".$conf_name."</span></a>";
				}
				if (mysql_num_rows($result_sub_a) > 0) $menu_user_list .= "<ul class='nav nav-second-level' id='c_ul_".$conf_sub."'>";
				while(@$row_sub_a=mysql_fetch_array($result_sub_a)) {
					$conf_name = $row_sub_a['conf_name'];
					$conf_url = $row_sub_a['conf_url'];
					$conf_sub = $row_sub_a['conf_sub'];
					$menu_user_list .= "<li id='a_li_".$conf_sub."'><a class='J_menuItem' href='".$conf_url."' id='a_a_".$conf_sub."'>".$conf_name.$i."</a></li>";
				}
				if (mysql_num_rows($result_sub_a) > 0) $menu_user_list .= "</ul>";
				$menu_user_list .= "</li>";
			}
		}
		echo $menu_user_list;
	}
	function home_user_center() 
	{ 
		global $mysql_conn,$v_file;
		$user_id = $_COOKIE['user_id'];
		$user_name = $_COOKIE['user_name'];
		$user_type = $_COOKIE['user_type'];
		$type_name = $_COOKIE['type_name'];
		$sql = "SELECT * from `notice` order by notice_id desc limit 0,1;";
		$result = mysql_query($sql,$mysql_conn);
		while(@$row=mysql_fetch_array($result)) {
			$notice_id = $row['notice_id'];
			$notice_title = $row['notice_title'];
			$notice_body = $row['notice_body'];
			$list1 .= "<p>".$notice_title."</p>";
			$list1 .= "<p>".$notice_body."</p>";
		}
		$sql = "SELECT * from `article` order by article_id desc limit 0,1;";
		$result = mysql_query($sql,$mysql_conn);
		while(@$row=mysql_fetch_array($result)) {
			$article_id = $row['notice_id'];
			$article_title = $row['article_title'];
			$article_body = $row['article_body'];
			$list2 .= "<p>".$article_title."</p>";
			$list2 .= "<p>".$article_body."</p>";
		}
		$sql = "SELECT * from `notice` order by notice_id desc limit 1,1;";
		$result = mysql_query($sql,$mysql_conn);
		while(@$row=mysql_fetch_array($result)) {
			$notice_id = $row['notice_id'];
			$notice_title = $row['notice_title'];
			$notice_body = $row['notice_body'];
			$list3 .= "<div class='panel panel-default'><div class='panel-heading'>";
			$list3 .= "<h5 class='panel-title'><a data-toggle='collapse' data-parent='#version' href='#v".$notice_id."'>".$notice_title."</a></h5></div>";
			$list3 .= "<div id='v".$notice_id."' class='panel-collapse collapse in'><div class='panel-body'>";
			$list3 .= "<div class='alert alert-warning'>".$notice_body."</div>";
			$list3 .= "</div></div></div>";
		}
		$sql = "SELECT * from `notice` order by notice_id desc limit 2,4;";
		$result = mysql_query($sql,$mysql_conn);
		while(@$row=mysql_fetch_array($result)) {
			$notice_id = $row['notice_id'];
			$notice_title = $row['notice_title'];
			$notice_body = $row['notice_body'];
			$list3 .= "<div class='panel panel-default'><div class='panel-heading'>";
			$list3 .= "<h5 class='panel-title'><a data-toggle='collapse' data-parent='#version' href='#v".$notice_id."'>".$notice_title."</a></h5></div>";
			$list3 .= "<div id='v".$notice_id."' class='panel-collapse collapse '><div class='panel-body'>";
			$list3 .= "<div class='alert alert-warning'>".$notice_body."</div>";
			$list3 .= "</div></div></div>";
		}
		$sql = "SELECT * from `user` WHERE `user_id` = '".$user_id."' ";
		$result = mysql_query($sql,$mysql_conn);
		@$row=mysql_fetch_array($result);
		$user_bot_num = $row['user_bot_num'];
		$user_type_time_end = $row['user_type_time_end'];
		$user_glod = $row['user_glod'];
		$sql = "SELECT * from `bot` WHERE `bot_user_id` = '".$user_id."' ";
		$result = mysql_query($sql,$mysql_conn);
		$user_bot_num_now = mysql_num_rows($result);
		
		require($v_file);
	}
	function home_user_set() 
	{ 
		global $mysql_conn,$v_file;
		$user_id = $_COOKIE['user_id'];
		$user_name = $_COOKIE['user_name'];
		$user_type = $_COOKIE['user_type'];
		$type_name = $_COOKIE['type_name'];
		$sql = "SELECT * from `user` WHERE `user_id` = '".$user_id."'";
		$result = mysql_query($sql,$mysql_conn);
		@$row = mysql_fetch_array($result);
		$user_password = $row['user_password'];
		require($v_file);
	}
	function home_user_set_do() 
	{ 
		global $mysql_conn;
		$user_id = $_COOKIE['user_id'];
		$user_password = $_POST['user_password'];
		$sql = "UPDATE `user` SET `user_password` = '".$user_password."' WHERE `user_id` =".$user_id.";";
		$result = mysql_query($sql,$mysql_conn);
		@$row = mysql_fetch_array($result);
		echo "1";
	}
} 
/* End of file democontroller.php */ 